package accountManagementNew.controller;

import accountManagementNew.common.base.Result;
import accountManagementNew.common.pojo.ConsumptionType;
import accountManagementNew.common.vo.BlurDataVO;
import accountManagementNew.common.vo.ConsumptionTypeVO;
import accountManagementNew.service.IConsumptionTypeService;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：lihonbin
 * @version：2025/9/3
 * @description 消费类型控制层
 */
@RestController
@RequestMapping("/consumptionType")
@AllArgsConstructor
public class ConsumptionTypeController {


    private final IConsumptionTypeService consumptionTypeService;

    /**
     * 查询所有启用的消费类型
     * @return 消费类型列表
     */
    @GetMapping("/queryAll")
    public Result< List<ConsumptionTypeVO>> queryAllConsumptionType() {
        List<ConsumptionType> consumptionTypeList = consumptionTypeService.queryAllConsumptionType();
        List<ConsumptionTypeVO> consumptionTypeVOList = new ArrayList<>();
        consumptionTypeList.forEach(consumptionType -> {
            ConsumptionTypeVO consumptionTypeVO = new ConsumptionTypeVO();
            BeanUtils.copyProperties(consumptionType, consumptionTypeVO);
            consumptionTypeVOList.add(consumptionTypeVO);
        });
        return Result.success(consumptionTypeVOList);
    }


}
